package com.example.back.config;

import com.example.back.common.JwtInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @author Jm
 * @date 2024/7/13
 */
@Configuration
public class InterceptorConfig extends WebMvcConfigurationSupport
{

    @Override
    protected void addInterceptors(InterceptorRegistry registry)
    {
        // 配置jwt的拦截器规则
        registry.addInterceptor(jwtInterceptor())
                // 拦截所有的请求路径
                .addPathPatterns("/**")
                .excludePathPatterns("/user/login");

        super.addInterceptors(registry);
    }

    @Bean
    public JwtInterceptor jwtInterceptor()
    {
        return new JwtInterceptor();
    }

}